
import java.util.Scanner;

class JGARCOM {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        int T = 0;
        int N = entrada.nextInt();

        for (int i = 0; i < N; i++) {
            int L = entrada.nextInt();
            int C = entrada.nextInt();
            if (L > C) {
                T += C;
            }
        }
        System.out.println(T);
    }
}
